]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
authPrompt: add support for auth without username
authorRay Strode <rstrode@redhat.com>
Sun, 28 Jul 2013 21:49:50 +0000 (17:49 -0400)
committerRay Strode <rstrode@redhat.com>
Mon, 19 Aug 2013 01:14:35 +0000 (21:14 -0400)
This commit introduces a new BeginRequestType enum which gets
passed to the 'reset' signal to specify whether
a username should be provided to the begin() method and changes
the loginDialog to comply.

Currently, the signal only ever gets emitted with

AuthPrompt.BeginRequestType.PROVIDE_USERNAME

but that will change in the future when providing smartcard
support.

https://bugzilla.gnome.org/show_bug.cgi?id=683437

js/gdm/authPrompt.js
js/gdm/loginDialog.js
js/ui/unlockDialog.js

index 15841a3fb3f4bd47edd94e3bb22bd30ac897bcca..c7648c2925f0b6a5b0607e77f786e0f1f3a7683d 100644 (file)
@@ -31,6 +31,11 @@ const AuthPromptStatus = {
     VERIFICATION_SUCCEEDED: 3
 };
 
+const BeginRequestType = {
+    PROVIDE_USERNAME: 0,
+    DONT_PROVIDE_USERNAME: 1
+};
+
 const AuthPrompt = new Lang.Class({
     Name: 'AuthPrompt',
 
@@ -431,7 +436,7 @@ const AuthPrompt = new Lang.Class({
         if (oldStatus == AuthPromptStatus.VERIFICATION_FAILED)
             this.emit('failed');
 
-        this.emit('reset');
+        this.emit('reset', BeginRequestType.PROVIDE_USERNAME);
     },
 
     addCharacter: function(unichar) {
index 46bd8959f3625d516dd55b3d5cb072e55c6e4eb2..b01ea3772010c01c625afc111d512d582bcd2835 100644 (file)
@@ -475,7 +475,12 @@ const LoginDialog = new Lang.Class({
                                                 x_align: St.Align.START,
                                                 x_fill: true });
 
-        this._notListedButton.connect('clicked', Lang.bind(this, this._hideUserListAndLogIn));
+        this._notListedButton.connect('clicked',
+                                      Lang.bind(this, function() {
+            this._authPrompt.cancelButton.show();
+            this._hideUserListAndLogIn();
+        }));
+
         this._notListedButton.hide();
 
         this._userSelectionBox.add(this._notListedButton,
@@ -585,15 +590,17 @@ const LoginDialog = new Lang.Class({
         this._showPrompt();
     },
 
-    _onReset: function() {
+    _onReset: function(authPrompt, beginRequest) {
         this._sessionMenuButton.updateSensitivity(true);
 
         this._user = null;
 
-        if (this._disableUserList)
+        if (this._disableUserList) {
+            this._authPrompt.cancelButton.hide();
             this._hideUserListAndLogIn();
-        else
+        } else {
             this._showUserList();
+        }
     },
 
     _onDefaultSessionChanged: function(client, sessionId) {
@@ -634,7 +641,7 @@ const LoginDialog = new Lang.Class({
         this._authPrompt.setHint(_("(e.g., user or %s)").format(hint));
     },
 
-    _askForUsernameAndLogIn: function() {
+    _askForUsernameAndBeginVerification: function() {
         this._authPrompt.setPasswordChar('');
         this._authPrompt.setQuestion(_("Username: "));
 
@@ -818,11 +825,20 @@ const LoginDialog = new Lang.Class({
         this._userSelectionBox.visible = expanded;
     },
 
-    _hideUserListAndLogIn: function() {
+    _hideUserList: function() {
         this._setUserListExpanded(false);
         if (this._userSelectionBox.visible)
             GdmUtil.cloneAndFadeOutActor(this._userSelectionBox);
-        this._askForUsernameAndLogIn();
+    },
+
+    _hideUserListAskForUsernameAndBeginVerification: function() {
+        this._hideUserList();
+        this._askForUsernameAndBeginVerification();
+    },
+
+    _hideUserListAndBeginVerification: function() {
+        this._hideUserList();
+        this._authPrompt.begin();
     },
 
     _showUserList: function() {
index 8f30d6e955286955d48323ece67094e5d95b0a75..13a2bd416308d68f6989b0002aa20cfa7842641f 100644 (file)
@@ -51,7 +51,7 @@ const UnlockDialog = new Lang.Class({
         this._authPrompt = new AuthPrompt.AuthPrompt(new Gdm.Client(), AuthPrompt.AuthPromptMode.UNLOCK_ONLY);
         this._authPrompt.connect('failed', Lang.bind(this, this._fail));
         this._authPrompt.connect('cancelled', Lang.bind(this, this._fail));
-        this._authPrompt.setUser(this._user);
+        this._authPrompt.connect('reset', Lang.bind(this, this._onReset));
         this._authPrompt.setPasswordChar('\u25cf');
         this._authPrompt.nextButton.label = _("Unlock");
 
@@ -75,7 +75,7 @@ const UnlockDialog = new Lang.Class({
             this._otherUserButton = null;
         }
 
-        this._authPrompt.begin({ userName: this._userName });
+        this._authPrompt.reset();
         this._updateSensitivity(true);
 
         Main.ctrlAltTabManager.addGroup(this.actor, _("Unlock Window"), 'dialog-password-symbolic');
@@ -97,6 +97,18 @@ const UnlockDialog = new Lang.Class({
         this.emit('failed');
     },
 
+    _onReset: function(authPrompt, beginRequest) {
+        let userName;
+        if (beginRequest == AuthPrompt.BeginRequestType.PROVIDE_USERNAME) {
+            this._authPrompt.setUser(this._user);
+            userName = this._userName;
+        } else {
+            userName = null;
+        }
+
+        this._authPrompt.begin({ userName: userName });
+    },
+
     _escape: function() {
         if (this.allowCancel)
             this._authPrompt.cancel();